********************************************************************************************************************
*****Do-file for Figure A1
*****Who is mobilized to vote by short text messages? Evidence from a nationwide field experiment with young voters
********************************************************************************************************************
*****Last edited 24/6/5
********************************************************************************************************************
*****Ado packages needed: estout
********************************************************************************************************************


*set seed
set seed 23581017
*Use data
use \data\dataforanalysis230522_v2.dta, clear

*************************************************
*****Figure A1
*************************************************


*Split sample and generate predictions
keep if treatment==0

splitsample, gen(ssample1) values(0 1)


logit voted22 female molincome  firstvote foreign i.moses1d i.mohighschool i.kunta19 if ssample1==0
predict logit1
elasticnet logit voted22 female molincome  firstvote foreign i.moses1d i.mohighschool i.kunta19 if  ssample1==0
predict enet1





bys shnro: gen sample_n=_n


gen logit_pred=logit1 if sample_n==1


gen enet_pred=enet1 if sample_n==1


gen outsample=ssample1 if sample_n==1




****************





*ROC AUC graphs


roccomp voted22 logit_pred enet_pred if outsample==1, graph plot1opts(lpattern(dash)) plot2opts(lpattern(solid))
capture graph close

roccomp voted22 logit_pred enet_pred if outsample==0 , graph plot1opts(lpattern(dash)) plot2opts(lpattern(solid))
capture graph close



